#include <sys/timerfd.h>
#include <iostream>
#include <cstring>
#include <unistd.h>
using namespace std;

int main()
{
    int timerfd = timerfd_create(CLOCK_MONOTONIC, 0);
    struct itimerspec tims;
    memset(&tims, 0, sizeof tims);
    tims.it_value.tv_sec = 3;
    tims.it_interval.tv_sec = 1;
    timerfd_settime(timerfd, 0, &tims, nullptr);
    sleep(10);
    uint64_t t;
    while(true)
    {
        sleep(2);
        ssize_t n = read(timerfd, &t, 8);
        printf("%ld\n", n);
    }
    return 0;
}